package cn.nsu.douban.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.nsu.douban.dao.dao.IUserDao;
import cn.nsu.douban.entity.User;
import cn.nsu.douban.service.IUserService;

@Service
@Transactional
public class IUserServiceImpl implements IUserService {

	@Autowired
	private IUserDao iuserdao;

	public void setIuserdao(IUserDao iuserdao) {
		this.iuserdao = iuserdao;
	}

	@Transactional(readOnly = true)
	public User login(String loginname, String password) {

		return iuserdao.loginByloginNameAndPasswod(loginname, password);
	}

	public Integer findUsername(String username) {
		
		return iuserdao.findUsername(username);
	}

	public void register(User user) throws Exception {
             iuserdao.save(user);         
		
	}

}
